--License
--	This file is part of AssTermo.
--
--    AssTermo is free software: you can redistribute it and/or modify it
--    under the terms of the GNU General Public License as published by
--    the Free Software Foundation, either version 3 of the License, or
--    (at your option) any later version.
--
--    AssTermo is distributed in the hope that it will be useful, but WITHOUT
--    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
--    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
--    for more details.
--
--    You should have received a copy of the GNU General Public License
--    along with AssTermo.  If not, see <http://www.gnu.org/licenses/>.
--
--Description
--    en locale, English (will be the same for en_GB and en_US)
words.en = {
	"Water",
	"Ammonia",
	"Refrigerant R22"
	"Refrigerant R134a"
	"Propane",

	"Search for P and/or T",
	"Search for h and P",
	"Search for s and P (Table)",
	"Search for s and P (Saturated Liquid)",
	"Search for v and P",
	"Search for u and P",

	"Molar masses and R's",

	"Acetylene",
	"Air (equivalent)",
	"Argon",
	"Benzene",
	"Carbon",
	"Carbon dioxide",
	"Carbon monoxide",
	"Copper",
	"Ethane",
	"Ethyl alcohol",
	"Ethylene",
	"Helium",
	"Hydrogen",
	"Methane",
	"Methyl alcohol",
	"Octane",
	"Oxygen",
	"Propylene",
	"Refrigerant R12",
	"Sulfur dioxide",

	"Specific Heat",
	"Search for T",
	"Search for cp",
	"Search for cv",
	"Search for cp/cv",
	"View Table"

	"Psychrometrics Assistant",

	"Pressure (bar):",

	"Obtain w",
	"w: With pv",
	"w: With HR and T",
	"w: With the masses",

	"Obtain HR",
	"HR: With T and w",
	"HR: With T and pv",
	"HR: With pv and pvSat",

	"Obtain h with T and w",
	"Obtain p->T or T->p",
	"Obtain pvSat with T",
	"Obtain T with pvSat",

	"Obtain steam p (pv)",
	"pv: With HR and T",
	"pv: With w",

	"Calculate masses",
	"(m,w) -> (ma,mv)",
	"(ma,w) -> (mv)",
	"(mv,w) -> (ma)",
	"(m,mv) -> (ma)",
	"(m,ma) -> (mv)",
	"(ma,mv) -> (m)",

	"Psychrometrics Diagram",
	"Add points",
	"Change points",
	"Remove points",
	"Intersect straight lines",
	"View Diagram",
	"Obtain hs and hl",
	"Points info",
	"Clear All",

	"Air Table",

	"Search for h",
	"Search for u",
	"Search for s0",
	"Search for pr",
	"Search for vr",

	"Combustion Assistent",
	"Ideal Gases Properties",
	"TermoChemical Properties",
	"Log10(K)",
	"(T\V)mode:",
	"Chemical Solver",

	"Equation:",
	"Add Reagentes:",
	"Add Produtos:",
	"Alterar Reagentes",
	"Alterar Produtos",
	"Remove Reagentes",
	"Remove Produtos",
	"See Equations",
	"Solve Incognits",
	"Clear Equations",
	"Calculo Entalpias Totais",
	"Calculo Temperaturas Intermédias",
	"See Listed Entalpies",
	"Clear Entalpias",

	"Interpolations",
	"About AssTermo-D"
}
--End of EN locale
--License
--	This file is part of AssTermo.
--
--    AssTermo is free software: you can redistribute it and/or modify it
--    under the terms of the GNU General Public License as published by
--    the Free Software Foundation, either version 3 of the License, or
--    (at your option) any later version.
--
--    AssTermo is distributed in the hope that it will be useful, but WITHOUT
--    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
--    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
--    for more details.
--
--    You should have received a copy of the GNU General Public License
--    along with AssTermo.  If not, see <http://www.gnu.org/licenses/>.
--
--Description
--    pt locale, Portuguese
words.pt = {
	"Água",
	"Amónia",
	"Refrigerante R22",
	"Refrigerante R134a",
	"Propano",

    "Procurar por P e/ou T",
    "Procurar por h e P",
    "Procurar por s e P (Tabela)",
	"Procurar por s e P (Liquido Saturado)",
	"Procurar por v e P",
	"Procurar por u e P",

	"Massas Molares e R's",

	"Acetylene",
	"Air (equivalent)",
	"Argon",
	"Benzene",
	"Carbon",
	"Carbon dioxide",
	"Carbon monoxide",
	"Copper",
	"Ethane",
	"Ethyl alcohol",
	"Ethylene",
	"Helium",
	"Hydrogen",
	"Methane",
	"Methyl alcohol",
	"Octane",
	"Oxygen",
	"Propylene",
	"Refrigerant 12",
	"Sulfur dioxide",

	"Calor Específico", --Specific heat
	"Procurar por T",
	"Procurar por cp",
	"Procurar por cv",
	"Procurar por cp/cv",
	"Ver Tabela",

	"Assistente de Psicometria",

	"Pressao (bar):",

	"Obter w",
	"w Tendo pv",
	"w: Tendo HR e T",
	"w: Tendo as massas",

	"Obter HR",
	"HR: Com T e w",
	"HR: Com T e pv",
	"HR: Com pv e pvSat",

	"Obter h com T e w",
	"Obter p->T ou T->p",
	"Obter pvSat com T",
	"Obter T com pvSat",

	"Obter p vapor (pv)",
	"pv: Tendo HR e T",
	"pv: Tendo w",

	"Cálculo de massas",
	"(m,w) -> (ma,mv)",
	"(ma,w) -> (mv)",
	"(mv,w) -> (ma)",
	"(m,mv) -> (ma)",
	"(m,ma) -> (mv)",
	"(ma,mv) -> (m)",

	"Diagrama Psicometrico",
	"Adicionar pontos",
	"Alterar pontos",
	"Remover pontos",
	"Intersectar rectas",
	"Ver Diagrama",
	"Obter hs e hl",
	"Informação dos pontos",
	"Apagar Todos",

	"Tabela do Ar",

	"Procurar por h",
	"Procurar por u",
	"Procurar por s0",
	"Procurar por pr",
	"Procurar por vr",

	"Assistente de Combustão",
	"Prop. Gases Ideais",
	"Prop. TermoQuímicas",
	"Log10(K)",
	"Modo(T\V): Valores",

	"Solver Quimico",
	"Equação:",
	"Adicionar Reagentes:",
	"Adicionar Produtos:",
	"Alterar Reagentes",
	"Alterar Produtos",
	"Remover Reagentes",
	"Remover Produtos",
	"Ver Equações",
	"Solve Incógnitas",
	"Apagar Equações",
	"Cálculo Entalpias Totais",
	"Cálculo Temperaturas Intermédias",
	"Ver Entalpias Listadas",
	"Apagar Entalpias",

	"Interpolações",
	"Sobre o AssTermo-D"
}
--End of Portuguese locale
--H2O table file

--End of H2O table file
--License
--	This file is part of AssTermo.
--
--    AssTermo is free software: you can redistribute it and/or modify it
--    under the terms of the GNU General Public License as published by
--    the Free Software Foundation, either version 3 of the License, or
--    (at your option) any later version.
--
--    AssTermo is distributed in the hope that it will be useful, but WITHOUT
--    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
--    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
--    for more details.
--
--    You should have received a copy of the GNU General Public License
--    along with AssTermo.  If not, see <http://www.gnu.org/licenses/>.
--
--Description
--    Main File

--
COPYRIGHT = string.uchar(0xa9)
DEGREE = string.uchar(0xb0)
SUPER_2 = string.uchar(0xb2)
SUPER_3 = string.uchar(0xb3)
MICRO = string.uchar(0xb5)
ARING = string.uchar(0xc5)
SUBSCRIPT_2 = string.uchar(0x2082)
NEGATIVE = string.uchar(0x2212)
PLACE_OF_INTEREST = string.uchar(0x2318)
EE = string.uchar(0xf000)
--

function tr(str)
	return str
end

function NotImp() -- "Not Implemented Function" disclaimer

end

menu = {
	{tr("Water"),
	   {tr("Search for P and/or T"),NotImp},
	   {tr("Search for h and P"),NotImp},
	   {tr("Search for s and P (Table)"),NotImp},
	   {tr("Search for s and P (Saturated Liquid)"),NotImp},
	   {tr("Search for v and P"),NotImp},
	   {tr("Search for u and P"),NotImp}
	},
	{tr("Ammonia"),
	   {tr("Search for P and/or T"),NotImp},
	   {tr("Search for h and P"),NotImp},
	   {tr("Search for s and P (Table)"),NotImp},
	   {tr("Search for s and P (Saturated Liquid)"),NotImp},
	   {tr("Search for v and P"),NotImp},
	   {tr("Search for u and P"),NotImp}
	},
	{tr("Refrigerant R22"),
	   {tr("Search for P and/or T"),NotImp},
	   {tr("Search for h and P"),NotImp},
	   {tr("Search for s and P (Table)"),NotImp},
	   {tr("Search for s and P (Saturated Liquid)"),NotImp},
	   {tr("Search for v and P"),NotImp},
	   {tr("Search for u and P"),NotImp}
	},
	{tr("Refrigerant R134a"),
	   {tr("Search for P and/or T"),NotImp},
	   {tr("Search for h and P"),NotImp},
	   {tr("Search for s and P (Table)"),NotImp},
	   {tr("Search for s and P (Saturated Liquid)"),NotImp},
	   {tr("Search for v and P"),NotImp},
	   {tr("Search for u and P"),NotImp}
	},
	{tr("Propane"),
	   {tr("Search for P and/or T"),NotImp},
	   {tr("Search for h and P"),NotImp},
	   {tr("Search for s and P (Table)"),NotImp},
	   {tr("Search for s and P (Saturated Liquid)"),NotImp},
	   {tr("Search for v and P"),NotImp},
	   {tr("Search for u and P"),NotImp}
	},
	{tr("Molar masses and R's"),
	   {tr("Acetylene"),NotImp},
	   {tr("Air (equivalent)"),NotImp},
	   {tr("Ammonia"), NotImp},
	   {tr("Argon"),NotImp},
	   {tr("Benzene"),NotImp},
	   {tr("Carbon"),NotImp},
	   {tr("Carbon dioxide"),NotImp},
	   {tr("Carbon monoxide"),NotImp},
	   {tr("Copper"),NotImp},
	   {tr("Ethane"),NotImp},
	   {tr("Ethyl alcohol"),NotImp},
	   {tr("Ethylene"),NotImp},
	   {tr("Helium"),NotImp},
	   {tr("Hydrogen"),NotImp},
	   {tr("Methane"),NotImp},
	   {tr("Methyl alcohol"),NotImp},
	   {tr("Octane"),NotImp},
	   {tr("Oxygen"),NotImp},
	   {tr("Propane"),NotImp},
	   {tr("Propylene"),NotImp},
	   {tr("Refrigerant 12"),NotImp},
	   {tr("Refrigerant 22"),NotImp},
	   {tr("Refrigerant 134a"),NotImp},
	   {tr("Sulfur dioxide"),NotImp},
	   {tr("Water"),NotImp}
	},
	{tr("Specific Heat"),
		{tr("Search for T"),NotImp},
		{tr("Search for cp"),NotImp},
		{tr("Search for cv"),NotImp},
		{tr("Search for cp/cv"),NotImp},
		{tr("View Table"),NotImp}
	},
	{tr("Psychrometrics Assistant"),

		{tr("Pressure (bar):"),NotImp},

		{tr("Obtain w"),
			{tr("w: With pv",NotImp},
			{tr("w: With HR and T",NotImp},
			{tr("w: With the masses",NotImp}
		},

		{tr("Obtain HR"),
			{tr("HR: With T and w",NotImp},
			{tr("HR: With T and pv",NotImp},
			{tr("HR: With pv and pvSat",NotImp}
		},
		{tr("Obtain h with T and w",NotImp},
		{tr("Obtain p->T or T->p",
			{tr("Obtain pvSat with T",NotImp},
			{tr("Obtain T with pvSat",NotImp},
		},
		{tr("Obtain steam p (pv)",
			{tr("pv: With HR and T",NotImp},
			{tr("pv: With w",NotImp},
		},
		{tr("Calculate masses",
			{tr("(m,w) -> (ma,mv)",NotImp},
			{tr("(ma,w) -> (mv)",NotImp},
			{tr("(mv,w) -> (ma)",NotImp},
			{tr("(m,mv) -> (ma)",NotImp},
			{tr("(m,ma) -> (mv)",NotImp},
			{tr("(ma,mv) -> (m)",NotImp},
		},
		{tr("Psychrometrics Diagram",
			{tr("Add points",NotImp},
			{tr("Change points",NotImp},
			{tr("Remove points",NotImp},
			{tr("Intersect straight lines",NotImp},
			{tr("View Diagram",NotImp},
			{tr("Obtain hs and hl",NotImp},
			{tr("Points info",NotImp},
			{tr("Clear All",NotImp},
		},
	},
	{tr("Air Table",
		{tr("Search for T"),NotImp},
		{tr("Search for h",NotImp},
		{tr("Search for u",NotImp},
		{tr("Search for s0",NotImp},
		{tr("Search for pr",NotImp},
		{tr("Search for vr",NotImp},
		{tr("View Table"),NotImp}
	},
	{tr("Combustion Assistent",
		{tr("Ideal Gases Properties",NotImp},
		{tr("TermoChemical Properties",NotImp},
		{tr("Log10(K)",NotImp},
		{tr("(T\V)mode:",NotImp},
		{tr("Chemical Solver",
			{tr("Equation:"),
				{tr("Add Reagents:"),NotImp}
				{tr("Add Products:"),NotImp}
				{tr("Alterar Reagents"),NotImp}
				{tr("Alterar Products"),NotImp}
				{tr("Remove Reagents"),NotImp}
				{tr("Remove Products"),NotImp}
				{tr("See Equations"),NotImp}
				{tr("Solve Unknowns"),NotImp}
				{tr("Clear Equations"),NotImp}
			}
			{tr("Calculate Total Enthalpies"),NotImp}
			{tr("Calcule Intermediate Temperatures"),NotImp}
			{tr("See Listed Enthalpies"),NotImp}
			{tr("Clear Enthalpies"),NotImp}
		},
	},
	{tr("Interpolations",NotImp},
	{"---"},
	{tr("About AssTermo-D"),NotImp}
}

toolpalette.register(menu)

-- End of Main File
--Graphics File
gc=platform.gc()

--BetterLua API
local function test(arg)
	return arg and 1 or 0
end

local function screenRefresh()
	return platform.window:invalidate()
end

local function pww()
	return platform.window:width()
end

local function pwh()
	return platform.window:height()
end

local function verticalBar(x)
	myGC:fillRect(x,0,1,platform.window:height())
end

local function horizontalBar(y)
	myGC:fillRect(0,y,platform.window:width(),1)
end
local function drawSquare(x,y,l)
	myGC:drawPolyLine({(x-l/2),(y-l/2), (x+l/2),(y-l/2), (x+l/2),(y+l/2), (x-l/2),(y+l/2), (x-l/2),(y-l/2)})
end
local function drawPoint(x, y)
	myGC:fillRect(x, y, 1, 1)
end
local function drawCircle(x, y, diameter)
	myGC:drawArc(x - diameter/2, y - diameter/2, diameter,diameter,0,360)
end

local function drawCenteredString(str)
	myGC:drawString(str, (pww() - myGC:getStringWidth(str)) / 2, pwh() / 2, "middle")
end

local function drawXCenteredString(str,y)
	myGC:drawString(str, (pww() - myGC:getStringWidth(str)) / 2, y, "top")
end
Color = {
	["black"] = {0, 0, 0},
	["red"] = {0xff, 0, 0},
	["green"] = {0, 0xff, 0},
	["blue "] = {0, 0, 0xff},
	["white"] = {0xff, 0xff, 0xff},
	["brown"] = {165,42,42},
	["cyan"] = {0,255,255},
	["darkblue"] = {0,0,139},
	["darkred"] = {139,0,0},
	["fuchsia"] = {255,0,255},
	["gold"] = {255,215,0},
	["gray"] = {127,127,127},
	["grey"] = {127,127,127},
	["lightblue"] = {173,216,230},
	["lightgreen"] = {144,238,144},
	["magenta"] = {255,0,255},
	["maroon"] = {128,0,0},
	["navyblue"] = {159,175,223},
	["orange"] = {255,165,0},
	["palegreen"] = {152,251,152},
	["pink"] = {255,192,203},
	["purple"] = {128,0,128},
	["royalblue"] = {65,105,225},
	["salmon"] = {250,128,114},
	["seagreen"] = {46,139,87},
	["silver"] = {192,192,192},
	["turquoise"] = {64,224,208},
	["violet"] = {238,130,238},
	["yellow"] = {255,255,0}
}
local function setColor(theColor)
	if type(theColor) == "string" then
		theColor = string.lower(theColor)
		if type(Color[theColor]) == "table" then myGC:setColorRGB(unpack(Color[theColor])) end
	elseif type(theColor) == "table" then
		myGC:setColorRGB(unpack(theColor))
	end
end
---end of BetterLua API thanks to Adriweb
local function drawCenteredRect(x0,y0)
	local pos={x0=math.floor(pww()-x0/2),y0=math.floor(pwh()-y0/2)}
	myGC:drawRect(pos.x0,pos.y0,size.x0,size.y0)
end

function Text(title,content)
	h1=gc:getStringHeight(title)
	w1=gc:getStringWidth(title)
	h2=gc:getStringHeight(content)
	w2=gc:getStringWidth(content)
	h=h1+h2
	if w1>w2 then
		w=w1
		else
		w=w2
	end
	window(w,h)
	gc:setColorRGB(200,200,200)
	gc:drawString(title,x+(w-w1)/2,y+math.floor(h1/2),"middle")
	gc:setColorRGB(0,0,0)
	gc:drawString(content,x+(w-w2)/2,y+h1+math.floor(h2/2),"middle")
end
function window(x,y)
	local size={x=x>=60 or 60,y=y>=100 or 100}
	if size.x<60
	or size.y<100 then
		error("Size is too small for window()")
	elseif size.x>pww() or size.y>pwh() then
		error("Size is too big for window()")
	end
	position={x=math.floor((pww()-size.x)/2),y=math.floor((pwh()-size.y)/2)}
	setColor("silver")
	gc:fillRect(position.x,position.y,w,h+k)
	setColor("black")
	gc:fillRect(x,y,w,k)
	gc:setPen("thin","smooth")
	if true then
	end
end
function on.paint(gc)
	myGC=gc
	Text("Esta mesmo assim","ok")
end
--End of Graphics File
